package exteditapp;

import exteditapp.state.IState;

/**
 * Listener interface for listeners of main program module.
 * 
 * Part of Observer Software Pattern implementation, which allows register several interfaces for
 * same subject and interface's states will change simultaneously as subject's state changes.
 * This is Listener (or Observer) interface - class, which implements this interface is able to
 * track changes in Subject's state. Then it is registered to Subject its {@link #update(IState)} 
 * method is invoked every time then Subject is changed or updated.
 * @author Arturas Smorgun, arturas@smorgun.lt
 * @version 2009.04.21
 */
public abstract class IListener  {

	/**
	 * Link to subject which this Listener listens.
	 */
	protected ISubject subject;

	/**
	 * Return subject, which is being listened by current listener
	 * @return subject, which listener watches
	 */	
	public ISubject getSubject(){
		return this.subject;
	}	

	/**
	 * Set the value of subject. It then will be listened for a changes and updates by this listener
	 * @param mySubject set subject, which we will be watching
	 */
	public void setSubject(ISubject mySubject){
		this.subject = mySubject;
	}	
	
	/**
	 * Tells listener, what subject is changed and we should do some operations in Listener to react
	 * on these changes.
	 * @param fileState updates listener's condition depending on new state
	 */
	public abstract void update(IState fileState);
		
}
